<?php

/**
 * BecaOtorgada filter form.
 *
 * @package    BecArTe
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class BecaOtorgadaFormFilter extends BaseBecaOtorgadaFormFilter
{
  public function configure()
  {
    $this->EmbedForm('alumno', new EmbeddedAlumnoFormFilter());
    $this->widgetSchema['beca_id'] = new sfWidgetFormDoctrineChoice(array(
            'model' => 'Beca',
            'order_by' => array('nombre','ASC'),
            'add_empty' => true));
    $this->validatorSchema['beca_id'] = new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Beca', 'column' => 'id'));

  }


  public function addBecaIdColumnQuery(Doctrine_Query $query, $field, $values)
  { 
    if(!is_null($values['beca_id'])) 
      $query->leftJoin(sprintf('%s.solicitud sol', $query->getRootalias()) )
            ->andWhere('sol.beca_id = ?', $values['beca_id']);
  }

  public function addAlumnoColumnQuery(Doctrine_Query $query, $field, $values)
  { 
    $this->getEmbeddedForm('alumno')
            ->addAlumnoFieldsQuery($query, $field, $values);
  }
}
